<?php
namespace Wx\Controller;
use Think\Controller;


class MySetController extends CommonController {

//   个人设置
    public function index(){
        $mobile = M('member')->where('id = '.session('u_id'))->getField('mobile');
        $this->assign('mobile',$mobile);
        $this->display('set');
    }// end fun index()

    // 绑定手机号 - 未做完
    public function bind(){
        if(IS_POST){
            $post = I('post.');
            if(empty($post)){
                $this->error('请填写手机号');
            }// end if
            $res = M('member')->where('id = '.session('u_id'))->setField('mobile',$post['mobile']);
            if($res){
                $this->success('绑定成功');
            }else{
                $this->error('提交失败，请检查');
            }// end if
        }else{

            $this->display('phone');
        }// end if

    }// end fun bind()

    // 支付密码
    public function password(){
        $order_id = intval(I('order_id'));
        if(IS_POST){
            $post = I('post.');
            if($post['pay_pwd']!=$post['repwd']){
                $this->error('两次输入的密码不一致');
            }// end if
            $pay_pwd = md5($post['pay_pwd']);
            $res = M('member')->where('id = '.session('u_id'))->setField('pay_pwd',$pay_pwd);
            if($res){
                if(!empty($post['order_id'])){//如果是从支付页面来的，跳转到支付页面
                    $this->success('提交成功','/Api/Weixinpay/choosePay/order_id/'.$order_id);
                }else{
                    $this->success('提交成功','/Wx/User/index');
                }// end if
            }else{
                $this->error('提交失败，请检查');
            }// end if
        }else{
            $this->assign('order_id',$order_id);
            $this->display();
        }// end if
    }// end fun password()


}// end class
